<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="com.zmht.specedu.vo.Teachbook,com.zmht.specedu.vo.Soundstudy,java.util.*"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	/**
	 * @author 谭湘元
	 * @since 2009/04/23
	 */

 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030" />
<title>聋校语言学习及矫治系统</title>
<fmt:setBundle basename="PathResource" scope="session" />
<link href="<%=request.getContextPath() %>/<fmt:message key='StylePath' />style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath() %>/<fmt:message key='jquery' />ajaxHelper.js"></script>
<script type="text/javascript"
	src="<fmt:message key='datePicker' />WdatePicker.js"></script>
	<script type="text/javascript">
	function submitForm1(){
		var tbookName = document.forms[0].tbookName.value.RTrim();
		if(tbookName==""){
			alert("教材名称必须填写！");
			document.forms[0].tbookName.focus();
			return;
		}
		if(document.forms[0].time.value.RTrim()==""){
			alert("时间必须填写！");
			document.forms[0].time.focus();
			return;
		}
		var scoreText = document.forms[0].scoreText.value.RTrim();
		if(scoreText == ""){
			alert("评分目标必须填写！");
			document.forms[0].scoreText.focus();
			return;
		}else{
			 while(scoreText.indexOf("，")!=-1)//寻找每一个中文逗号，并替换
			 {
				 scoreText=scoreText.replace("，",",");
			 }
		}
		var re = new RegExp("^([a-z]+[\\d])$");
		var parts = scoreText.split(",");
		for(var i=0;i<parts.length;i++){
			if(!re.test(parts[i])){
				alert("评分目标输入必须为字母和数字的组合,多个以逗号分隔！");
				document.forms[0].scoreText.focus();
				document.forms[0].scoreText.select();
				return;
			}
		}
		var inputs = document.getElementsByTagName("input");
		for(var i=0;i<inputs.length;i++){
			if(inputs[i].type=="file"){
				var value = inputs[i].value;
				//alert(value);
				if(value==""){
					continue;
				}
				var accept = inputs[i].accept;
				//alert(accept);
				if(accept=="" || accept=="undefine"){
					continue;
				}
				
				var endwith = value.substring(value.lastIndexOf(".")+1);
				//alert(endwith);
				if(accept.toLowerCase().indexOf(endwith)< 0){
					var message = inputs[i].message;
					if(message){
						alert(message+" 必须以"+accept+"结尾!");
					}else{
						alert("所选文件必须以"+accept+"结尾!");
					}
					inputs[i].focus();
					return;
				}
			}
		}
		var remark = document.forms[0].remark.value;
		if(remark.length>100){
			alert("描述最多只能输入100个字！");
			document.forms[0].remark.select();
			return;
		}
		document.forms[0].submit();
	}
	function addNewWord(e,obj){
		if(obj.value.length>100){
			e.returnValue = false;
		}
	}
		<%--function finalTypeChanged(currentValue){
			<%
				String[] finalTypes = Teachbook.finalTypes;
				List bookTypes = (List)request.getAttribute("teachBookTypes");
				StringBuffer soundStudyString = new StringBuffer();
				StringBuffer soundRescueString = new StringBuffer();
				for(int x = 0;x<bookTypes.size();x++){
					Soundstudy type = (Soundstudy) bookTypes.get(x);
					if(type.getTbookType().equals(finalTypes[0])){
						soundStudyString.append(type.getId()).append(",").append(type.getName()).append("|");
					}else{
						soundRescueString.append(type.getId()).append(",").append(type.getName()).append("|");
					}
				}
				if(soundStudyString.length()>0) soundStudyString.deleteCharAt(soundStudyString.length()-1);
				if(soundRescueString.length()>0) soundRescueString.deleteCharAt(soundRescueString.length()-1);
			%>
			var idValueString="";
			if(currentValue=="<%=finalTypes[0] %>"){
				idValueString = "<%=soundStudyString.toString()%>";
			}else if(currentValue=="<%=finalTypes[1] %>"){
				idValueString = "<%=soundRescueString.toString()%>";
			}
			if(idValueString=="") return;

			var bookTypeSelect = document.forms[0].tbookType;
			bookTypeSelect.options.length=0;
			var optionValueLabels = idValueString.split("|");
			for(var i=0;i<optionValueLabels.length;i++){
				var valueLabel = optionValueLabels[i].split(",");
				bookTypeSelect.options.add(new Option(valueLabel[1],valueLabel[0]));
			}
			
		}--%>
		window.onload = function(){
			var successFlag = "<c:out value="${addTeachBookSuccess}" />"
			if(successFlag!="")
				alert(successFlag);
		}
	</script>
	
</head>

<body class="bcolor">
<form action="teachBook.do?method=addTeachBook" method="post" enctype="multipart/form-data" name="teachBookForm" id="form1">
	<input name="author" type="hidden" value="<c:out value="${current_user_session_key.tname }"/>"/>
  <table cellspacing="0" cellpadding="0" width="96%" align="center" border="0" style="margin:0;padding:0;">
	<tbody>
	<tr>
        <td width="7"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_01.gif" width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_05.gif"><table cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td width="30"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_02.gif" width="30" /></td>
                <td align="left" width="200" background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_03.gif">&nbsp;<strong>增 加 教 材</strong></td>
                <td width="59"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_04.gif" width="59" /></td>
                <td>&nbsp;</td>
              </tr>
            </tbody>
        </table></td>
        <td width="8"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_06.gif" width="8" /></td>
    </tr>
    <tr>
		<td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_07.gif"><img height="1" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
        <td bgcolor="#f7fbff">
      <table cellspacing="0" bordercolordark="#ccccff" cellpadding="0" width="100%" bordercolorlight="#ffffff" border="0">
	  	<tbody>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材名称：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="tbookName" type="text" class="boxcopy2" id="textfield10"  style="width:295px;" maxlength="50"/>
                      <span class="STYLE4">*</span></td>
                </tr>
            </table></td>
          </tr>
          <%-- <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">目标类别：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<select name="finalType" class="boxcopy2" id="select4" style="width:120px;" onchange="finalTypeChanged(this.value);">
						<% 
							for(int i=0;i<finalTypes.length;i++){
						%>	
                      <option <%if(i==0) out.print("selected");%> value="<%=finalTypes[i] %>"><%=finalTypes[i] %></option>
						<%
							}
						 %>
                  </select></td>
                </tr>
            </table></td>
          </tr>--%>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材类别：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<select name="tbookType" class="boxcopy2" id="select5" style="width:300px;">
						<c:forEach items="${teachBookTypes}" var="bookType" varStatus="status">
							<option value="<c:out value="${bookType.id}" />" <c:if test="${status.index==0}">selected</c:if>>
								<c:out value="${bookType.name}"></c:out>
							</option>
						</c:forEach>
						<%-- 
							for(int i=0;i<bookTypes.size();i++){
								Soundstudy type = (Soundstudy) bookTypes.get(i);
								if(type.getTbookType().equals(finalTypes[0])){
						%>	
                      <option value="<%=type.getId() %>" <%if(i==0) out.print("selected");%>><%=type.getName() %></option>
						<%
								}
							}
						 --%>
                  	</select></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材等级：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><select name="tbookClass" class="boxcopy2" id="select6" style="width:300px;">
                      <% 
							String[] teachBookLevels = Teachbook.teachBookLevels;
							for(int i=0;i<teachBookLevels.length;i++){
						%>	
                      <option <%if(i==0) out.print("selected");%>><%=teachBookLevels[i] %></option>
						<%
							}
						 %>
                  </select></td>
                </tr>
            </table></td>
          </tr>
          <%--<tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教师姓名：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="textfield" type="text" class="boxcopy2" id="textfield2"  style="width:100px;"/></td>
                </tr>
            </table></td>
          </tr> 
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">作 者：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="author" type="text" class="boxcopy2" id="textfield"  style="width:100px;"/>
                      <span class="STYLE4">*</span></td>
                </tr>
            </table></td>
          </tr>--%>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">时 间：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
						<input name="time" type="text" class="boxcopy2" id="textfield18" 
							onfocus="new WdatePicker(this,'%Y-%M-%D',true,'whyGreen');"  style="width:295px;" maxlength="4"/> <span class="STYLE4">*</span>
                    </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">评分目标：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="scoreText" type="text" class="boxcopy2" id="textfield29"  style="width:295px;" maxlength="40"/> <span class="STYLE4">*</span> 有多个目标用逗号隔开,一个目标对应一个教材</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">说 明：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><textarea name="remark" rows="5" class="boxcopy2" id="textfield30" style="width:295px;" onpropertychange="if(value.length>100) value=value.substr(0,100)"></textarea> 最多可输入100个字符</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">汉字文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="chineseFile" type="file" contentEditable="false" class="boxcopy2" id="fileField" style="width:300px;" message="汉字文件" accept="jpg" />
				  </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">口型文件(*.avi)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="mouthFile" type="file" contentEditable="false" class="boxcopy2" id="fileField2" style="width:300px;" message="口型文件" accept="avi" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">拼音文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="pinyinFile" type="file" contentEditable="false" class="boxcopy2" id="fileField3" style="width:300px;" message="拼音文件" accept="jpg" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">声音文件(*.wav)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="soundFile" type="file" class="boxcopy2" contentEditable="false" id="fileField4" style="width:300px;" message="声音文件" accept="wav" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">手势文件(*.avi)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="signFile" type="file" class="boxcopy2" id="fileField5" contentEditable="false" style="width:300px;" message="手势文件" accept="avi" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">图片文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="pictureFile" type="file" class="boxcopy2" contentEditable="false" id="fileField6" style="width:300px;" message="图片文件" accept="jpg" /></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">字母文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="zimuFile" type="file" class="boxcopy2" contentEditable="false" id="fileField7" style="width:300px;" message="字母文件" accept="jpg" /></td>
                </tr>
            </table></td>
          </tr>
			</tbody>
        </table>
        <table cellspacing="1" cellpadding="0" width="100%" bgcolor="#ffffff" border="0">
           <tbody>
                <tr>
                  <td valign="middle" bgcolor="#e6f0f8"><table cellspacing="0" cellpadding="3" width="100%" border="0">
                      <tbody>
			            <tr>
			              <td width="50%" height="20" align="right"><a href="javascript:submitForm1();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-01.gif" border="0" /></a>&nbsp;</td>
			              <td height="20" align="left">&nbsp;<a href="javascript:document.forms[0].reset();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-02.gif" border="0" /></a></td>
			            </tr>
       				 </tbody>
                  </table></td>
                </tr>
           </tbody>
        </table>
		</td>
		<td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_09.gif"><img height="1" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
    </tr>
    <tr>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_10.gif" width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_11.gif">&nbsp;</td>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_12.gif" width="8" /></td>
      </tr>
	</tbody>
  </table>
</form>
</body>
</html>
